#define  _CRT_SECURE_NO_WARNINGS 1

#include"Sort.h"

void Swap(int* arr1, int* arr2)
{
	int tmp = *arr1;
	*arr1 = *arr2;
	*arr2 = tmp;
}

void BubbleSort(int* arr, int size)
{
	int flag = 0;

	for (int j = 0; j < size - 1; j++)
	{
		int cur = 0;
		while (cur < size - 1 - j)
		{
			if (arr[cur] > arr[cur + 1])
			{
				Swap(&arr[cur], &arr[cur + 1]);
				flag = 1;
			}
			cur++;
		}

		if (flag == 0)
		{
			return;
		}
	}
}